home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
Evatac Software
/
Preditor 3.0
/
Samples
/
Source Sample.cp
< prev
Wrap
Text File
|
1995-11-05
|
3KB
|
111 lines
/******************************************************************************
CToolsDir.c
The ToolsDir Class
Director for the Tools tear-off menu
SUPERCLASS = CTearOffMenu
Copyright © 1989 Symantec Corporation. All rights reserved.
TCL 2.0 changes:
[
- replaced calls to I-methods with constructor calls.
]
******************************************************************************/
#include "Global.h"
#include "CCharGrid.h"
#include "CSelectorMDEF.h"
#include "CToolsDir.h"
#include "ArtClassCmds.h"
#include "CWindow.h"
/*** Global Variables ***/
extern CBureaucrat *gGopher; /* First in line to get commands */
extern short gPaintTool; /* The current painting tool */
/*** Class Contstants ***/
#define WINDtools 1003 /* Resource ID for tools window */
/******************************************************************************
CToolsDir
Initialize a ToolsDir object
******************************************************************************/
CToolsDir::CToolsDir(CApplication *aSupervisor) : CTearOffMenu(WINDtools)
{
CCharGrid *theTools;
CSelectorMDEF *theSelectorMDEF;
short width;
short height;
Rect sizeRect;
itsWindow->SetActClick(TRUE);
theTools = new CCharGrid(MENUtools, itsWindow, this);
theTools->gridOn = TRUE;
theTools->Activate();
theTools->selection = gPaintTool;
/* Make window same size as Tools */
/* without lines on the edges */
theTools->GetLengths(&width, &height);
SetRect(&sizeRect, width-1, height-1, width, height);
itsWindow->SetSizeRect(&sizeRect);
itsWindow->ChangeSize(width-1, height-1);
itsPane = theTools;
SetRect(&margins, 1, 10, 1, 1); /* One pixel frame with a 10 pixel */
/* drag bar on the top side */
theSelectorMDEF = new CSelectorMDEF(MENUtools, itsPane, this);
itsWindow->MoveOffScreen(); /* Put window out of sight until */
itsWindow->Select(); /* needed */
}
/******************************************************************************
DoCommand {OVERRIDE}
Handle commands for the selection of a tool
******************************************************************************/
void CToolsDir::DoCommand(
long theCommand)
{
Str255 commandStr;
if (HiShort(-theCommand) == ((CCharGrid*)itsPane)->GetCommandBase()) {
/* Item from Tools was selected */
gGopher->DoCommand(theCommand);
} else {
CTearOffMenu::DoCommand(theCommand);
}
}
/******************************************************************************
SelectTool
Set the current tool selection
******************************************************************************/
void CToolsDir::SelectTool(
short theTool)
{
itsPane->Prepare();
((CCharGrid*)itsPane)->ChangeSelection(theTool);
}